import { FormRule } from 'tdesign-vue-next';

import { getPwdStrength } from '@/components/pwdStrength/data';

export const stepsList = [
  { label: '账户验证', value: 1, icon: 'steps-device_validate' },
  { label: '修改密码', value: 2, icon: 'steps-reset_pwd' },
  { label: '重新登录', value: 3, icon: 'steps-relogin' },
];

export const INIT_DATA_ONE = { sn: '' };

export const FORM_RULES_ONE: Record<string, FormRule[]> = {
  sn: [{ required: true, message: '请输入设备序列号', trigger: 'blur' }],
};

export const INIT_DATA_TWO = { password: '', repassword: '' };

export const FORM_RULES_TWO: Record<string, FormRule[]> = {
  password: [
    { required: true, message: '请输入新密码', trigger: 'blur' },
    {
      validator: (value: string) => {
        if (getPwdStrength(value) < 2) {
          return { result: false, message: '密码安全性要求至少为“中等”', type: 'error' };
        }
        return { result: true, message: '', type: 'success' };
      },
    },
  ],
  repassword: [{ required: true, message: '请再输入一次新密码', trigger: 'blur' }],
};
